package cn.bzc.data.process.infra.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>异常类与http status对照关系</p>
 *
 * @author sprainkle
 * @date 2019/5/2
 * @see org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
 */
@Getter
@AllArgsConstructor
public enum ServletResponseEnum {
    METHOD_ARGUMENT_NOT_VALID_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"MethodArgumentNotValidException"),
    METHOD_ARGUMENT_TYPE_MISMATCH_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"MethodArgumentTypeMismatchException"),
    MISSING_SERVLET_REQUEST_PART_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"MissingServletRequestPartException"),
    MISSING_PATH_VARIABLE_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"MissingPathVariableException"),
    BIND_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"BindException"),
    MISSING_SERVLET_REQUEST_PARAMETER_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"MissingServletRequestParameterException"),
    TYPE_MISMATCH_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"TypeMismatchException"),
    SERVLET_REQUEST_BINDING_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"ServletRequestBindingException"),
    HTTP_MESSAGE_NOT_READABLE_EXCEPTION(4400, "", HttpServletResponse.SC_BAD_REQUEST,"HttpMessageNotReadableException"),
    NO_HANDLER_FOUND_EXCEPTION(4404, "", HttpServletResponse.SC_NOT_FOUND,"NoHandlerFoundException"),
    NO_SUCH_REQUESTHANDLING_METHOD_EXCEPTION(4404, "", HttpServletResponse.SC_NOT_FOUND,"NoSuchRequestHandlingMethodException"),
    HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION(4405, "", HttpServletResponse.SC_METHOD_NOT_ALLOWED,"HttpRequestMethodNotSupportedException"),
    HTTP_MEDIA_TYPE_NOT_ACCEPTABLE_EXCEPTION(4406, "", HttpServletResponse.SC_NOT_ACCEPTABLE,"HttpMediaTypeNotAcceptableException"),
    HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION(4415, "", HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE,"HttpMediaTypeNotSupportedException"),
    CONVERSION_NOT_SUPPORTED_EXCEPTION(4500, "", HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"ConversionNotSupportedException"),
    HTTP_MESSAGE_NOT_WRITABLE_EXCEPTION(4500, "", HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"HttpMessageNotWritableException"),
    ASYNC_REQUEST_TIMEOUT_EXCEPTION(4503, "", HttpServletResponse.SC_SERVICE_UNAVAILABLE,"AsyncRequestTimeoutException"),
    ;

    /**
     * 返回码，目前与{@link #statusCode}相同
     */
    private final int code;
    /**
     * 返回信息，直接读取异常的message
     */
    private final  String message;
    /**
     * HTTP状态码
     */
    private final int statusCode;

    /**
     * 异常名称
     */
    private final String exceptionName;
}
